<template>
  <div class="execution">
    <div style="text-align: right">
      <el-button @click="onlinePreview">预 览</el-button>
      <el-button @click="exportFileObj" plain :loading="exportWordLoading">下 载</el-button>
      <el-button @click ="flushBtn">刷 新</el-button>
    </div>
    <el-card class="box-card" shadow="always" v-if="flushSub">
      <h2 style="text-align: center;font-size: 28px;">罪犯暂予监外执行居住地核实情况表</h2>
      <table border="1" width="100%" height="90%" style="border-collapse:collapse;border:1px solid black;font-size: 16px;font-family: 仿宋_GB2312">
        <tr style="height: 35px">
          <td style="width: 16.67%;text-align: center">姓名</td>
          <td style="width: 18.67%;">{{ currentRow.zfxm }}</td>
          <td style="width: 16.67%;text-align: center">别名</td>
          <td style="width: 16.67%;">{{ currentRow.bm }}</td>
          <td style="width: 16.67%;text-align: center">民族</td>
          <td>{{currentRow.mz}}</td>
        </tr>
        <tr style="height: 35px">
          <td style="width: 16.67%;text-align: center">出生年月日</td>
          <td>{{currentRow.csrq}}</td>
          <td style="width: 16.67%;text-align: center;">罪 名</td>
          <td style="width: 16.67%" colspan="3">{{ currentRow.zm }}</td>
        </tr>
        <tr style="height: 35px">
          <td style="width: 16.67%;text-align: center">原判刑期</td>
          <td>{{formatxq(currentRow.yxq)}}</td>
          <td style="width: 16.67%;text-align: center;">现刑期<br/>起止</td>
          <td style="width: 16.67%" colspan="3">
            {{ currentRow.xxqq }}至{{ currentRow.xxqz }}
          </td>
        </tr>
        <tr style="height: 35px">
          <td style="width: 16.67%;text-align: center">户籍地</td>
          <td colspan="7">{{ currentRow.jtdzdqmc }}{{ currentRow.jtdzxx }}</td>
        </tr>
        <tr style="height: 35px">
          <td style="width: 16.67%;text-align: center;">捕前居住地</td>
          <td style="width: 16.67%" colspan="7">{{currentRow.bqjzd!=null?currentRow.bqjzd:currentRow.jtdzdqmc+''+currentRow.jtdzxx}}</td>
        </tr>
        <tr style="height: 120px">
          <td style="width: 16.67%;padding: 12px 0;text-align: center;">
            核实情况
          </td>
          <td style="width: 16.67%" colspan="7">{{ currentRow.verify.hsjzdqk }}</td>
        </tr>
        <tr style="height: 50px">
          <td style="width: 16.67%;padding: 12px 0;text-align: center;">已核实的暂予<br/>监外执行拟居<br/>住地</td>
          <td style="width: 16.67%" colspan="7">{{ currentRow.zxjzdmc }}{{ currentRow.zxjzdxx }}</td>
        </tr>
        <tr style="height: 120px">
          <td style="width: 16.67%;padding: 12px 0;text-align: center;">刑罚执行科<br/>意见</td>
          <td style="width: 16.67%;font-size: 1rem" colspan="7">
            <p style="text-indent:25px;word-break: break-all;">{{ currentRow.verify.hsjzdxfkyj }}</p>
            <p style="width: 40%;display: inline-block;text-align: left;margin: 0 0 5px 25px;float: left">
              签字：
<!--              <img :src="currentRow.verify.hsjzdxfkqz"
                   style="height:60px;width:110px;">-->
            </p>
            <p style="width: 50%;display: inline-block;text-align: right;margin: 40px 40px 5px 0;float: right">
              {{ currentRow.verify.hsjzdxfkrq }}
            </p>
            <div style="position:absolute;margin-top: -45px;right: 45px;">
<!--              <img :src="currentRow.verify.hsjzdxfkgz"
                   style="height:110px;width:110px;">-->
            </div>
          </td>
        </tr>
      </table>
    </el-card>
    <el-dialog
      :title="title"
      :fullscreen="true"
      :visible.sync="centerDialogVisible"
      width="85%"
      center>
      <viewFile :filePath="fileUrl"/>
    </el-dialog>
  </div>
</template>

<script>
import {getFirstTrialById,exportFileaddressVerify} from '@/api/punishment/outsidecriminal'
import {formOption} from '@/const/crud/archives/criminal/criminalnaturall'
import { downloadFileObj } from '@/util/util'
import viewFile from "@/components/iframe/viewFile";
export default {
  name: 'addressVerifyForm',
  props: ['id'],
  data() {
    return {
      currentRow: {
        firsttrial: {},
        appraisalList: [],
        guarantor: {},
        verify: {},
        approve: {},
      },
      formOption: formOption,
      exportWordLoading:false,
      flushSub:true,
      centerDialogVisible:false,
      fileUrl:undefined,
      title:"",
    }
  },
  created() {
    this.getCriminalInfo();
  },
  components: {viewFile},
  methods: {
    getCriminalInfo() {
      getFirstTrialById(this.id).then(res => {
        this.currentRow = res.data.data
      })
    },
    formatxq (val) {
      if (val && val !== '9995' && val !== '9996') {
        var nf = parseInt(val.substr(0, 2)) === 0 ? '' : parseInt(val.substr(0, 2)) + '年'
        var yf = parseInt(val.substr(3, 2)) === 0 ? '' : parseInt(val.substr(2, 2)) + '个月'
        var ts = parseInt(val.substr(5, 2)) === 0 ? '' : parseInt(val.substr(4, 2)) + '天'
        return nf + '' + yf + ts
      } else {
        if (val == '9995') {
          return '无期徒刑'
        }
        if(val=='9996'){
          return '死缓无期'
        }
        return val
      }
    },
    exportFileObj() {
      this.exportWordLoading = true
      exportFileaddressVerify({id: this.id}).then(result => {
        downloadFileObj(result.data, this.currentRow.zfxm+'暂予监外执行居住地核实情况表', 'pdf')
        this.exportWordLoading = false
      }).catch(() => {
        this.exportWordLoading = false
      })
    },
    flushBtn(){
      this.flushSub=false
      setTimeout(() => {
        this.flushSub=true
      }, 300)
    },
    onlinePreview(){
      this.centerDialogVisible  = true
      this.title = this.currentRow.zfxm + '暂予监外执行居住地核实情况表'
      this.fileUrl = "/punishment/outsidecriminal/exportFileaddressVerify?id="+this.id
    },
  }
}
</script>
